package Principal;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class CambiarColorFila extends DefaultTableCellRenderer {
	public Component getTableCellRendererComponent(  
			JTable table, Object value, boolean isSelected, 
			boolean hasFocus, int row, int col)
			{
			     Component comp = super.getTableCellRendererComponent(
			                      table,  value, isSelected, hasFocus, row, col);
			 
			     String s =  table.getModel().getValueAt(row, 1 ).toString();
			 //Solamente cambia cuando la fila 1 (stock actual) es igual a 0
			     if(s.equalsIgnoreCase("0")) 
			     {
			         comp.setForeground(Color.red);
			     }
			     else
			     {
			         comp.setForeground(null);
			     }
			 
			     return( comp );
			 }
}
